pub struct EndpointWriter {
    /// Remote system address
    address: String,
    /// Remote config
    config: Arc<RemoteConfig>,
    /// Serializer registry
    serializer_registry: Arc<SerializerRegistry>,
    /// Channel for outgoing messages
    message_sender: mpsc::Sender<EndpointWriterMessage>,
    /// gRPC client
    client: Option<RemotingClient<Channel>>,
    /// Message stream
    stream: Option<Streaming<RemoteMessage>>,
    /// Message batch buffer
    buffer: Vec<RemoteMessage>,
    /// Maximum batch size
    max_batch_size: usize,
}

impl EndpointWriter {
    /// Create a new endpoint writer
    pub fn new(
        address: String,
        config: Arc<RemoteConfig>,
        serializer_registry: Arc<SerializerRegistry>,
    ) -> Self {
        let (tx, _) = mpsc::channel(100);
        
        // 使用write_buffer_size作为最大批处理大小，如果不存在则使用默认值100
        let max_batch_size = config.write_buffer_size.unwrap_or(100);
        
        Self {
            address,
            config,
            serializer_registry,
            message_sender: tx,
            client: None,
            stream: None,
            buffer: Vec::with_capacity(max_batch_size),
            max_batch_size,
        }
    }
    
    // ... existing code ...
} 